package com.ruoyi.web.controller.teaching;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.Restaurant;
import com.ruoyi.teaching.service.IRestaurantService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 窗口信息Controller
 * 
 * @author ruoyi
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/teaching/restaurant")
public class RestaurantController extends BaseController
{
    @Autowired
    private IRestaurantService restaurantService;

    /**
     * 查询窗口信息列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:restaurant:list')")
    @GetMapping("/list")
    public TableDataInfo list(Restaurant restaurant)
    {
        startPage();
        List<Restaurant> list = restaurantService.selectRestaurantList(restaurant);
        return getDataTable(list);
    }

    /**
     * 导出窗口信息列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:restaurant:export')")
    @Log(title = "窗口信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Restaurant restaurant)
    {
        List<Restaurant> list = restaurantService.selectRestaurantList(restaurant);
        ExcelUtil<Restaurant> util = new ExcelUtil<Restaurant>(Restaurant.class);
        util.exportExcel(response, list, "窗口信息数据");
    }

    /**
     * 获取窗口信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:restaurant:query')")
    @GetMapping(value = "/{rName}")
    public AjaxResult getInfo(@PathVariable("rName") String rName)
    {
        return success(restaurantService.selectRestaurantByRName(rName));
    }

    /**
     * 新增窗口信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:restaurant:add')")
    @Log(title = "窗口信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Restaurant restaurant)
    {
        return toAjax(restaurantService.insertRestaurant(restaurant));
    }

    /**
     * 修改窗口信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:restaurant:edit')")
    @Log(title = "窗口信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Restaurant restaurant)
    {
        return toAjax(restaurantService.updateRestaurant(restaurant));
    }

    /**
     * 删除窗口信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:restaurant:remove')")
    @Log(title = "窗口信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rNames}")
    public AjaxResult remove(@PathVariable String[] rNames)
    {
        return toAjax(restaurantService.deleteRestaurantByRNames(rNames));
    }
}
